// AA3.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream"
#include "fstream"
using namespace std;
struct amir
{
int ID;
int pass;
char name[10];
}amir;
int _tmain(int argc, _TCHAR* argv[])
{
ofstream wfile("amirhosen.txt",ios::out|ios::binary);
cout<<"hay do you sabtenam(yes_1)(no_2)";
if (!wfile.is_open())
{
exit(0);
}
int a;
cin>>a;
if (a==1)
{
cout<<"inter name/n";
cin>>amir.name;
cout<<"inter ID/n";
cin>>amir.ID;
cout<<"inter pass/n";
cin>>amir.pass;
wfile.write((char*)&amir,sizeof(struct amir));
wfile.close();
cout<<"OK you are caman in the shool/n";
}
if (a==2)
{
exit(0);
}
ifstream rfile("amirhosen.txt",ios::in|ios::binary);
if (!rfile.is_open())
{
exit(0);
}
cout<<"do you coman to ID(yes_1)(no_2)";
int h,id;
cin>>h;
if(h=1)
{
cout<<"pleas inter the ID";
cin>>id;
while(rfile.read((char*)&amir,sizeof(struct amir)))
if(id==amir.ID)
{
cout<<"yuor ID:"<<amir.ID<<endl;
cout<<"your pass:"<<amir.pass<<endl;
cout<<"your name:"<<amir.name;
}
else if (h=2)
{
exit(0);
}
else
cout<<"you are dont sabt name in the shool";
{
}
}
cin>>amir.ID;
return 0;
}
این رو در ویژیال استدیو بزنید و حالشو ببرید
:: برچسبها:
آموزش برنامه نویسی ,